var serverPre1 ='http://10.150.30.54'
//var serverPre1 ='http://10.150.26.183';
serverPre1 = serverPre
function getApprovalCommonFunc() {
    var result = {};
    result.getUserByFuzzy = function (userName, callBackFunc) {
        if (isBlank(userName)) {
            return [];
        }
        var layerIndex = null;
        $.ajax({
            type: 'get',
            url: serverPre1 + "/manager/saas/v1/user/users?userName=" + encodeURIComponent(userName),
            headers: {"token": getCookie("token")},
            async: true,
            cache: false,
            beforeSend: function () {
                layerIndex = layer.load(2)
            },
            success: function (result) {
                if (result.code == 0) {
                    callBackFunc(result.data)
                } else {
                    callBackFunc([])
                    layer.msg(result.msg, {icon: 1, time: 2000});
                }
                if (layerIndex != null) {
                    layer.close(layerIndex)
                }
            }
        });
    };
    result.getFirstApprover = function () {
        var userInfos = []
        $.ajax({
            type: 'get',
            url: serverPre1 + "/api/auth/v1/approver/first?serviceAlias=SIGNATURE",
            headers: {"token": getCookie("token")},
            async: false,
            cache: false,
            success: function (result) {
                if (result.code == 0) {
                    userInfos = result.data;
                } else {
                    layer.msg(result.msg, {icon: 1, time: 2000});
                }
            }
        });
        return userInfos;
    };
    result.getSuperiors = function () {
        var results = [];
        $.ajax({
            type: 'get',
            url: serverPre1 + "/manager/saas/v1/user/superiors",
            headers: {"token": getCookie("token")},
            async: false,
            cache: false,
            success: function (result) {
                if (result.code == 0 && result.data) {
                    for (var i = 0; i < result.data.length; i++) {
                        result.data[i]["status"] = 0;
                        results.push(result.data[i])
                    }
                } else {
                    layer.msg(result.msg, {icon: 1, time: 2000});
                }
            }
        });
        return results;
    };
    return result;
}
function isNotBlank(s) {
    return s != undefined && s != null && (s + "").trim().length > 0
}

function isBlank(s) {
    return !isNotBlank(s);
}
